<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>商品出库</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .form-container {
            max-width: 500px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            border-radius: 4px;
        }
        h2 {
            color: #333;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input, select {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            padding: 10px 15px;
            background: #dc3545;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
            font-size: 16px;
        }
        button:hover {
            background: #c82333;
        }
        .stock-info {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }
        .warning {
            color: #dc3545;
            font-weight: bold;
        }
    </style>
</head>
<body>
<div class="form-container">
    <h2>商品出库</h2>
    <form id="stockOutForm">
        <div class="form-group">
            <label for="productSelect">选择商品</label>
            <select id="productSelect" required>
                <option value="">-- 请选择商品 --</option>
                <option value="P1001">iPhone 13 (库存: 50)</option>
                <option value="P1002">MacBook Pro (库存: 3)</option>
            </select>
            <div id="stockInfo" class="stock-info"></div>
        </div>
        <div class="form-group">
            <label for="quantity">出库数量</label>
            <input type="number" id="quantity" min="1" required>
        </div>
        <div class="form-group">
            <label for="operator">操作人</label>
            <input type="text" id="operator" required>
        </div>
        <div class="form-group">
            <label for="customer">客户/用途</label>
            <input type="text" id="customer" required>
        </div>
        <button type="submit">提交出库</button>
    </form>
</div>

<script>
    document.getElementById('stockOutForm').addEventListener('submit', function(e) {
        e.preventDefault();
        const productName = document.getElementById('productSelect').options[document.getElementById('productSelect').selectedIndex].text;
        const quantity = document.getElementById('quantity').value;
        const customer = document.getElementById('customer').value;

        if(confirm(`确认将商品【${productName.split(' ')[0]}】出库${quantity}件给【${customer}】吗？`)) {
            alert(`商品出库成功！`);
            this.reset();
        }
    });

    document.getElementById('productSelect').addEventListener('change', function() {
        if(this.value === 'P1001') {
            document.getElementById('stockInfo').innerHTML = '当前库存: 50 | 预警值: 10';
            document.getElementById('quantity').max = '50';
        } else if(this.value === 'P1002') {
            document.getElementById('stockInfo').innerHTML = '<span class="warning">当前库存: 3 (低于预警值5)</span>';
            document.getElementById('quantity').max = '3';
        } else {
            document.getElementById('stockInfo').innerHTML = '';
        }
    });
</script>
</body>
</html>